/**
 * @param {number[]} nums
 * @return {number}
 */
 var longestSubarray = function(nums) {
    let max = Math.max(...nums),res = 1;
    // console.log('max: ', max);
    for(let i = 1; i < nums.length; i++){
        let t = nums[i - 1] & nums[i];
        max = Math.max(t,max);
    //    if(t > max){
    //        res = 2;
    //        max = t;
    //    }else if(t == max){
    //        res++;
    //    }
    }
    let temp = 1;
    for(let i = 1; i < nums.length; i++){
        let t = nums[i - 1] & nums[i];
        console.log(t,max,res);
        if(t == max){
            temp ++;
            res = Math.max(temp,res);
        }else{
            temp = 1;
        }
    }
    console.log(max);
    return res;
};
let nums = [1,2,3,3,2,2];
nums = [395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,395808,470030,470030,470030,470030,470030,470030,470030,470030,470030,470030,470030,470030,470030,470030,470030,470030,470030,470030,470030,470030,470030,470030,470030,470030,153490,330001,330001,330001,330001,330001,330001,330001,37284,470030,470030,470030,470030,470030,470030,156542,226743];
console.log(longestSubarray(nums));